use "C:\Users\matha\Desktop\enviar laerte\FEMOBR_93536_Total 20160726.dta", clear

keep if type=="complete"
drop if P4B !=.

************Missing

mdesc

mdesc if type=="complete"


************Vari�veis descritivas de quem respondeu

tab SEXO if type=="complete"
* Distribui��o por sexo est� OK. Segue os valores de refer�ncia:
*Homem 49% - Mulher 51%

tab Regiao if type=="complete"
* Distribui��o por regi�o est� OK. Segue os valores de refer�ncia:
*Norte 8% - Nordeste 28% - Sudeste 42% - Sul 14% - Centro-Oeste 8%


tab br_socialclass if type=="complete"
* Distribui��o por calse est� OK. Segue os valores de refer�ncia:
* Classe A 6% - Classe B 33% - Classe C 61%

tab CS if type=="complete"


*Tamanho dos grupos
tab Treat_R if type=="complete"

*Tamanho da primeira e da segunda fase
tab base if type=="complete"

*************************************
*Dura��o das respostas
sum duration if type=="complete", detail
**M�dia de 283; Mediana 180


*Dura��o das respostas - Controle 
sum duration if type=="complete" & Treat_R==3, detail
**M�dia de 270; Mediana 178

*Dura��o das respostas - Tratamento 1
sum duration if type=="complete" & Treat_R==1, detail
**M�dia de 286; Mediana 183

*Dura��o das respostas - Tratamento 2
sum duration if type=="complete" & Treat_R==2, detail
**M�dia de 289; Mediana 181

*************************************
* Ideologia pol�tica
sum P6 if type=="complete", detail
*M�dia 5; Mediana 5

*Ideologia pol�tica - Controle 
sum P6 if type=="complete" & Treat_R==3, detail
*M�dia 5; Mediana 5

*Ideologia pol�tica - Tratamento 1
sum P6 if type=="complete" & Treat_R==1, detail
*M�dia 5; Mediana 5

*Ideologia pol�tica - Tratamento 2
sum P6 if type=="complete" & Treat_R==2, detail
*M�dia 5; Mediana 5

*************************************
*Partido Pol�tico
tab P5 if type=="complete"
* PT=26   ; PSDB=28

*Partido Pol�tico - Controle 
tab P5 if type=="complete" & Treat_R==3
* PT=27  ; PSDB=26

*Partido Pol�tico - Tratamento 1
tab P5 if type=="complete" & Treat_R==1
* PT= 25  ; PSDB=32

*Partido Pol�tico - Tratamento 2
tab P5 if type=="complete" & Treat_R==2
* PT=26   ; PSDB=27


*************************************
*Relev�ncia do Brasil
tab P1 if type=="complete"


*Relev�ncia do Brasil - Controle 
tab P1 if type=="complete" & Treat_R==3


*Relev�ncia do Brasil - Tratamento 1
tab P1 if type=="complete" & Treat_R==1


*Relev�ncia do Brasil - Tratamento 2
tab P1 if type=="complete" & Treat_R==2

*************************************
*Vis�o do Brasil
tab P2 if type=="complete"

*Vis�o do Brasil - Controle 
tab P2 if type=="complete" & Treat_R==3

*Vis�o do Brasil - Tratamento 1
tab P2 if type=="complete" & Treat_R==1

*Vis�o do Brasil - Tratamento 2
tab P2 if type=="complete" & Treat_R==2

*************************************
*Informa��o PE
tab P3 if type=="complete"

*Informa��o PE - Controle 
tab P3 if type=="complete" & Treat_R==3

*Informa��o PE - Tratamento 1
tab P3 if type=="complete" & Treat_R==1

*Informa��o PE - Tratamento 2
tab P3 if type=="complete" & Treat_R==2

*************************************
*ATE
*Controle
tab P4C  if type=="complete" 

*Tratamento 1 
tab  P4A if type=="complete" 

*Tratamento 2
tab P4B_Nova  if type=="complete" 




*************************************
*************************************
**** CREATE Treat Variable
gen treated=.

*** Control
replace treated=0 if type=="complete" & Treat_R==3

*** Treatment 1
replace treated=1  if type=="complete" & Treat_R==1

*** Treatment 2
replace treated=2 if type=="complete" & Treat_R==2



*************************************
**** CREATE P4_new Variable

* Define label
label define p4_label 1 "Totally cut the money destined to foreign aid." 2 "Diminish the money destined to foreign aid." 3 "Maintain the money destined to foreign aid." 4 "Increase the money destined to foreign aid."


*** Control
gen P4C_new=.
replace P4C_new=1 if P4C==4
replace P4C_new=2 if P4C==3
replace P4C_new=3 if P4C==2
replace P4C_new=4 if P4C==1

tab P4C P4C_new, nol

label values P4C_new p4_label 
tab P4C P4C_new, mis


*** Treatment 1
gen P4A_new=.
replace P4A_new=1 if P4A==4
replace P4A_new=2 if P4A==3
replace P4A_new=3 if P4A==2
replace P4A_new=4 if P4A==1

tab P4A P4A_new, nol

label values P4A_new p4_label 
tab P4A P4A_new, mis

*** Treatment 2
gen P4B_Nova_new=.
replace P4B_Nova_new=1 if P4B_Nova==4
replace P4B_Nova_new=2 if P4B_Nova==3
replace P4B_Nova_new=3 if P4B_Nova==2
replace P4B_Nova_new=4 if P4B_Nova==1

tab P4B_Nova P4B_Nova_new, nol

label values P4B_Nova_new p4_label 
tab P4B_Nova P4B_Nova_new, mis

*************************************
****  Treatment Mean Variable

*** Control
sum P4C_new if treated==0, detail

*** Treatment 1
sum P4A_new if treated==1, detail  

*** Treatment 2
sum P4B_Nova_new if treated==2, detail






*************************************
**** CREATE P4_outcome Variable

gen P4_outcome=.

replace P4_outcome=P4C_new if treated==0
replace P4_outcome=P4A_new if   treated==1
replace P4_outcome=P4B_Nova_new if  treated==2

label values P4_outcome p4_label 



*************************************
*************************************
*************************************
*************************************
**** Analysing as P4 continuous 

*** Diff between Control and Treat1
gen T01=.

replace T01=0 if treated==0
replace T01=1 if   treated==1

ttest P4_outcome, by(T01)
ttest P4_outcome, by(T01) unequal


*************************************
*** Diff between Control and Treat2
gen T02=.

replace T02=0 if treated==0
replace T02=1 if   treated==2



ttest P4_outcome, by(T02)
ttest P4_outcome, by(T02) unequal

*************************************
*** Diff between Treat1 and Treat2
gen T12=.

replace T12=0 if treated==1
replace T12=1 if   treated==2



ttest P4_outcome, by(T12)
ttest P4_outcome, by(T12) unequal



*****Conclusion: The groups are stastically differents



*************************************
*************************************
*************************************
*************************************
**** Analysing as P4 dichotomy
gen P4_outcome_01=.
replace P4_outcome_01=0 if P4_outcome==1 | P4_outcome==2
replace P4_outcome_01=1 if P4_outcome==3 | P4_outcome==4

tab P4_outcome_01 P4_outcome


*** Diff between Control and Treat1
prtest P4_outcome_01, by(T01) 
 
 
*************************************
*** Diff between Control and Treat2
prtest P4_outcome_01, by(T02) 


*************************************
*** Diff between Treat1 and Treat2
prtest P4_outcome_01, by(T12) 

*************************************
*************************************
*************************************
*************************************

**** Creating variables for the regressions


* Creating dummies for each region

gen norte =1 if Regiao ==3

replace norte=0 if norte ==.

gen sul =1 if Regiao==1
replace sul=0 if sul ==.

gen nordeste=1 if Regiao ==4
replace nordeste=0 if nordeste ==.

gen sudeste=1 if Regiao==2
replace sudeste=0 if sudeste ==.

gen centrooeste=1 if Regiao ==5
replace centrooeste=0 if centrooeste ==.

* Creating dummies for parties

gen PT=1 if P5==1
replace PT=0 if PT==.

gen PSDB=1 if P5==2
replace PSDB=0 if PSDB==.


* Creating new cagories for labor (employed (1) - not employed (0)

gen labornew =.
replace labornew =1 if int_situacaolaboral_sr==1
replace labornew =1 if int_situacaolaboral_sr==2

replace labornew =0 if int_situacaolaboral_sr==3
replace labornew =0 if int_situacaolaboral_sr==4
replace labornew =0 if int_situacaolaboral_sr==5
replace labornew =0 if int_situacaolaboral_sr==6
replace labornew =0 if int_situacaolaboral_sr==7
replace labornew =0 if int_situacaolaboral_sr==8
replace labornew =0 if int_situacaolaboral_sr==9

* Creating tratment and control variables

gen T1 =1 if treated==1
replace T1=0 if T1==.


gen T2 =1 if treated==2
replace T2=0 if T2==.

gen control =1 if treated==0
replace control=0 if control==.

**Recoding P6 = P6nova

gen P6nova=.
replace P6nova=1 if P6==0
replace P6nova=1 if P6==1
replace P6nova=1 if P6==2
replace P6nova=1 if P6==3
replace P6nova=1 if P6==4
replace P6nova=2 if P6==5
replace P6nova=3 if P6==6
replace P6nova=3 if P6==7
replace P6nova=3 if P6==8
replace P6nova=3 if P6==9
replace P6nova=3 if P6==10


** Recoding P1 = P1nova

gen P1nova = .
replace P1nova=1 if P1==4
replace P1nova=2 if P1==3
replace P1nova=3 if P1==2
replace P1nova=4 if P1==1


** Recoding P2 = P2nova

gen P2nova=.
replace P2nova=1 if P2==5
replace P2nova=2 if P2==4
replace P2nova=3 if P2==3
replace P2nova=4 if P2==2
replace P2nova=5 if P2==1

** recoding P3 = P3nova

gen P3nova=.
replace P3nova=1 if P3==5
replace P3nova=2 if P3==4
replace P3nova=3 if P3==3
replace P3nova=4 if P3==2
replace P3nova=5 if P3==1

**********************************************
**********************************************
**********************************************

** Generating tables

*** Table 01. Foreign Aid Support without Treatments

logit P4_outcome_01 SEXO EDAD br_socialclass P1nova P2nova P3nova labornew int_niveldeestudos_sr PT PSDB P6nova norte nordeste sudeste centrooeste if control==1

esttab, se r2


*** Table 02: Framing effects with control variables

logit P4_outcome_01 T2 if control==1 | T2==1
estimates store M1

logit P4_outcome_01 T1 if control==1 | T1==1
estimates store M2

logit P4_outcome_01 T2 SEXO EDAD br_socialclass P1nova P2nova P3nova labornew int_niveldeestudos_sr PT PSDB P6nova norte nordeste sudeste centrooeste if control==1 | T2==1
estimates store M3

logit P4_outcome_01 T1 SEXO EDAD br_socialclass P1nova P2nova P3nova labornew int_niveldeestudos_sr PT PSDB P6nova norte nordeste sudeste centrooeste if control==1 | T1==1

estimates store M4

logit P4_outcome_01 T2 T1 SEXO EDAD br_socialclass P1nova P2nova P3nova labornew int_niveldeestudos_sr PT PSDB P6nova norte nordeste sudeste centrooeste if control==1 | T1==1 | T2==1

estimates store M5

esttab M1 M2 M3 M4 M5, se r2

esttab M1 M2 M3 M4 M5 using table2.rtf, se r2 replace

esttab M1 M2 M3 M4 M5 using table2.csv, se r2 replace

*** Table 3: Descriptive Statistics

sum P4_outcome_01 SEXO EDAD br_socialclass P1nova P2nova P3nova labornew int_niveldeestudos_sr PT PSDB P6nova norte nordeste sudeste centrooeste sul if control==1

sum P4_outcome_01 SEXO EDAD br_socialclass P1nova P2nova P3nova labornew int_niveldeestudos_sr PT PSDB P6nova norte nordeste sudeste centrooeste sul if T1==1

sum P4_outcome_01 SEXO EDAD br_socialclass P1nova P2nova P3nova labornew int_niveldeestudos_sr PT PSDB P6nova norte nordeste sudeste centrooeste sul if T2==1


